// components/cityContent/cityContent.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    cityItem: {
      type: Object,
      value: null
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    wangData: null,
    flagState: null,
  },
  attached() {
    if (this.properties.cityItem) {
      let wang = this.properties.cityItem.list;
      let tempState = []
      tempState.push(this.properties.cityItem.hasOwnProperty('more'))
      this.setData({
        flagState: tempState
      })
      // console.log(this.properties.cityItem);
      this.likeIndex(wang)
      // console.log('disposeData-----',disposeData);
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    likeIndex(k) {
      let tempArray = []
      for (let i = 0; i < k.length; i++) {
        // console.log(String(k[i].clickCount).length);
        if (String(k[i].clickCount).length > 6) {
          tempArray.push(String(k[i].clickCount).slice(0, 3) + '万人气')
          // console.log(String(k[i].clickCount).slice(0,3) + '万');
        } else if (String(k[i].clickCount).length > 5) {
          tempArray.push(String(k[i].clickCount).slice(0, 2) + '万人气')
        } else if (String(k[i].clickCount).length < 3) {
          tempArray.push('最新发布')
        } else {
          tempArray.push(String(k[i].clickCount) + '人气')
        }
      }
      // console.log(tempArray);
      this.setData({
        wangData: tempArray
      })
    },
    // 跳转页面
    bookJump() {
      wx.navigateTo({
        url: '/pages/bookDetail/bookDetail',
        events: {
          acceptDataFromOpenedPage: function (data) {
            console.log(data)
          },
          someEvent: function (data) {
            console.log(data)
          }
        }
      })
    }

  }
})